<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/WEB-INF/taglib.jsp"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html>
    <head>
        <title>查看日志</title>
<%--        <link rel="stylesheet" type="text/css"  href="/common-web/resource/js/common/bootstrap.css"/>--%>
        <link rel="stylesheet" type="text/css"  href="${path}/resource/css/system/log/style.css" />
        <link rel="stylesheet" type="text/css"  href="${path}/resource/css/system/log/bootstrap.css" />
        <%@include file="/WEB-INF/jsp/include.jsp"%>
        <script type="text/javascript">
            var params = new Object();
            <%--var id = ${id};--%>
            $(function() {
                init();
            });

            function init(){
                params.id = $('#id').val();
                $.ajax({
                    type: "POST",
                    url: '${path}/system/log/view',
                    dataType: "json",
                    data: params,
                    success: function callback(data){
                        if(data.code=="0001"){
                            $.messager.alert('操作提示','查询出错','info');
                        }else{
                            var message =data.returnObject.rows[0];
                            var test = message.operator;
                            document.getElementById("operator").innerHTML = message.operator;
                            document.getElementById("clientIp").innerHTML = message.clientIp;
                            document.getElementById("sessionId").innerHTML = message.sessionId;
                            document.getElementById("url").innerHTML = message.url;
                            document.getElementById("paramData").innerHTML = message.paramData;
                            document.getElementById("returnData").innerHTML = message.returnData;
                            document.getElementById("exceptionMessage").innerHTML = message.exceptionMessage;
                            document.getElementById("startTime_endTime").innerHTML = dateUtil(message.startTime)+"----"+dateUtil(message.endTime);
                            document.getElementById("timeConsuming").innerHTML = message.timeConsuming+" ms";
                            document.getElementById("classMethod").innerHTML = message.classMethod;
                            document.getElementById("method").innerHTML = message.method;
                        }
                    },
                    error:function(){

                    }
                });
            }
            function dateUtil(value) {
                if (value !=null ) {
                    var date = new Date(value);
                    var year = date.getFullYear();
                    var month = date.getMonth() + 1;
                    var day = date.getDate();
                    var hour = date.getHours();
                    var minute = date.getMinutes();
                    var second = date.getSeconds();
                    return year + '-' + formartVal('0', month) + '-' + formartVal('0', day) + ' ' +
                        formartVal('0', hour) + ':' + formartVal('0', minute) + ':' + formartVal('0', second);
                }
            }

            function formartVal(prefix, val) {
                if(val < 10) {
                    return prefix + val;
                }
                return val;
            }
        </script>
    </head>
    <%@ include file="/WEB-INF/jsp/loading.jsp" %>
    <body   rlt="1">
    <div class="container">
        <input id ='id' type="hidden" value="${id}"/>
        <table class="table table-bordered responsive-utilities" style="background-color: #fff">
            <thead>
            <tr>
                <th width="250px" class="td_lable">操作人</th>
                <th id ='operator'></th>
            </tr>
            </thead>
            <tbody><tr>
                <td class="td_lable">操作IP</td>
                <td id="clientIp"></td>
            </tr>
            <tr>
                <td class="td_lable">sessionId</td>
                <td id ='sessionId'></td>
            </tr>
            <tr>
                <td class="td_lable">请求路径</td>
                <td id="url"></td>
            </tr>
            <tr>
                <td class="td_lable">类以及方法名</td>
                <td id="classMethod"></td>
            </tr>
            <tr>
                <td class="td_lable">请求方式</td>
                <td id="method"></td>
            </tr>
            <tr>
                <td class="td_lable">请求参数</td>
                <td id="paramData"></td>
            </tr>
            <tr>
                <td class="td_lable">返回参数</td>
                <td id="returnData"></td>
            </tr>
            <tr>
                <td class="td_lable">异常信息</td>
                <td id="exceptionMessage">
                </td>
            </tr>
            <tr>
                <td class="td_lable">请求时间</td>
                <td id="startTime_endTime"></td>
            </tr>
            <tr>
                <td class="td_lable">执行时间</td>
                <td id="timeConsuming"></td>
            </tr>

            </tbody></table>
    </div>
</body>
</html>
